package com.i.MyString.Question;

import java.util.Scanner;

/**
 * 统计每个数字的数量*/
public class TestQuestion15 {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);

        int sum1=0,sum2=0,sum3=0,sum4=0,sum5=0,sum6=0,sum7=0,sum8=0,sum9=0,sum0=0;
        String s="21928035610629831509813470";
        /*定义1，2，3
        * 将s 转换成char数组
        * 循环获取到char[i]
        * 利用switch case  进行计数
        */
        do {
            System.out.print("请输入查询的数字：");
            int number=input.nextInt();
            switch(number){
                case 1:
                    char[] a=s.toCharArray();
                    for (int i = 0; i < a.length; i++) {
                        if (a[i]=='1'){
                            sum1+=1;
                        }
                    }
                    System.out.println(sum1);
                    break ;
                case 2:
                    char[] a2=s.toCharArray();
                    for (int i = 0; i < a2.length; i++) {
                        if (a2[i]=='2'){
                            sum2+=1;
                        }
                    }
                    System.out.println(sum2);
                    break ;
                case 3:
                    char[] a3=s.toCharArray();
                    for (int i = 0; i < a3.length; i++) {
                        if (a3[i]=='3'){
                            sum3+=1;
                        }
                    }
                    System.out.println(sum3);
                    break ;
                case 4:
                    char[] a4=s.toCharArray();
                    for (int i = 0; i < a4.length; i++) {
                        if (a4[i]=='4'){
                            sum4+=1;
                        }
                    }
                    System.out.println(sum4);
                    break ;
                case 5:
                    char[] a5=s.toCharArray();
                    for (int i = 0; i < a5.length; i++) {
                        if (a5[i]=='5'){
                            sum5+=1;
                        }
                    }
                    System.out.println(sum5);
                    break ;
                case 6:
                    char[] a6=s.toCharArray();
                    for (int i = 0; i < a6.length; i++) {
                        if (a6[i]=='6'){
                            sum6+=1;
                        }
                    }
                    System.out.println(sum6);
                    break ;
                case 7:
                    char[] a7=s.toCharArray();
                    for (int i = 0; i < a7.length; i++) {
                        if (a7[i]=='1'){
                            sum7+=1;
                        }
                    }
                    System.out.println(sum7);
                    break ;
                case 8:
                    char[] a8=s.toCharArray();
                    for (int i = 0; i < a8.length; i++) {
                        if (a8[i]=='8'){
                            sum8+=1;
                        }
                    }
                    System.out.println(sum8);
                    break ;
                case 9:
                    char[] a9=s.toCharArray();
                    for (int i = 0; i < a9.length; i++) {
                        if (a9[i]=='1'){
                            sum9+=1;
                        }
                    }
                    System.out.println(sum9);
                    break ;
                case 0:
                    char[] a0=s.toCharArray();
                    for (int i = 0; i < a0.length; i++) {
                        if (a0[i]=='1'){
                            sum0+=1;
                        }
                    }
                    System.out.println(sum0);
                    break ;
                default:
                    System.out.println("没有该数字");
                    break;
            }
        }while(true);





    }
}
